<?php
$mTeacher = $this->maintenance;
$builder = $mTeacher->builder;
$builder->db = $this->db;
$db = $this->db;

$tabs = $db->query_select('cllg_table_tab', "TABLE_NAME='cllg_teacher'");
$sql = sprintf("select * from cllg_teacher where ID='%s'", getParam('IDT'));
$rows = $db->queryToArray($sql);
$row = $rows[0];
?>

<form id="<?php echo FORM_NAME; ?>" name="<?php echo FORM_NAME; ?>" method="post" action="<?php echo CORE_PATH; ?>" >
    <input type="hidden" id="module" name="module" value="<?php echo $this->instanceName; ?>" />
    <div id="mant_head">
        <div id="titulo">Datos Catedratico</div>
        <div id="botones">
            <button id="cmdOk" type="button" onclick="doSubmit('operation=u')">
                <img alt=""  src="imgv2/actions/document-save.png" />
            </button>
            <button id="cmdCancel" type="button" onclick="doSubmit('')">
                <img alt=""  src="imgv2/actions/window-close.png" />
            </button>
        </div>
    </div>
    <div id="tabs">
        <ul>
            <li><a href="#tab1">INFORMACION PRINCIPAL</a></li>
            <?php
            foreach ($tabs as $t) {
                $ix = $t["ID"];
                $tabId = "_tab_" . $ix;
                ?>
                <li ><a href="#<?php echo $tabId; ?>"><?php echo $t["CAPTION"]; ?></a></li>
                <?php
            }
            ?>
        </ul>
        <div class="form-container" id="tab1">
            <fieldset>
                <div>
                    <label for="ID">* Identificaci&oacute;n:</label>
                    <input name="ID" readonly="readonly" type="text" id="ID" value="<?php echo $row["ID"]; ?>" />
                </div>
                <div>
                    <label for="FRIST_NAME">* Nombres:</label>
                    <input name="FIRST_NAME"  type="text" value="<?php echo $row["FIRST_NAME"]; ?>" id="FIRST_NAME" size="50" maxlength="100" />
                </div>
                <div>
                    <label for="ID">* Apellidos:</label>
                    <input name="LAST_NAME"  type="text" id="LAST_NAME" size="50" maxlength="100"  value="<?php echo $row["LAST_NAME"]; ?>"/>
                </div>
                <div>
                    <label for="GENDER">* Sexo:</label>
                    <select name="GENDER" size="1" id="GENDER">
                        <option value="M" <?php
            if (!(strcmp("M", $row['GENDER']))) {
                echo "selected=\"selected\"";
            }
            ?>>Masculino</option>
                        <option value="F" <?php
                                if (!(strcmp("F", $row['GENDER']))) {
                                    echo "selected=\"selected\"";
                                }
            ?>>Femenino</option>
                    </select>
                </div>
                <div>
                    <label for="BIRTH_DATE">* Fecha Nacimiento:</label>
                    <input name="BIRTH_DATE" type="text" id="BIRTH_DATE" value="<?php echo date("d/m/Y", strtotime($row["BIRTHDATE"])); ?>" />
                    <input name="STATUS" type="hidden" id="STATUS" value="1" />
                </div>
                <div>
                    <label for="EDAD">Edad:</label>
                    <input name="EDAD" readonly="readonly" type="text" id="EDAD" value="<?php echo date("Y") - date("Y", strtotime($row["BIRTHDATE"])); ?>" />
                </div>  
                <div>
                    <label for="AGE">Correo Electr&oacute;nico:</label>
                    <input name="EMAIL" type="text" id="EMAIL" value="<?php echo $row["EMAIL"]; ?>" />
                </div>
                <div>
                    <label for="STATUS">* Estado:</label>
                    <select name="STATUS" size="1" id="STATUS">
                        <option value="1" <?php
                                if (!(strcmp(1, $row['STATUS']))) {
                                    echo "selected=\"selected\"";
                                }
            ?>>Activo</option>
                        <option value="0" <?php
                                if (!(strcmp(0, $row['STATUS']))) {
                                    echo "selected=\"selected\"";
                                }
            ?>>Inactivo</option>
                    </select>     
                </div>
                <div>
                    <label for="PICTUREPATH">*Fotografia:</label>
                    <div class="specialarea">
                        <div id="nuevafoto">
                            <div id="nuevafoto">
<?php if ($row['PICTURE_PATH'] != NULL) { ?>
                                    <img alt="foto"  width="200" height="200"
                                         src="<?php echo CORE_PATH . ModImages::$URL_IMAGES . strtoupper($row['PICTURE_PATH']) . ":80&" . AJAX_INDICATOR . "=true"; ?>" />
<?php } ?>
                            </div>

                        </div>
                        <a id="cargarFoto"
                           href="<?php echo CORE_PATH; ?>?module=<?PHP echo ModUploader::$INSTANCE_NAME ?>&op=uploader&<?php echo AJAX_INDICATOR; ?>=true">Cambiar</a>
                        <input name="PICTURE_PATH" type="hidden" id="PICTURE_PATH" value="<?php echo $row['PICTURE_PATH']; ?>" />
                    </div>
            </fieldset>
        </div>
        <?php
        $ix = 1;
        foreach ($tabs as $t) {
            $ix = $t["ID"];
            ?>
            <div id="<?php echo $ix; ?>"  class="TabbedPanelsContent">
                <div class="form-container" id="_tab_<?php echo $ix; ?>">
                    <fieldset>
    <?php $builder->build("cllg_teacher", $row['ID'], $t['ID']); ?>
                    </fieldset>
                </div>
                <?php
            }
            ?>
        </div>
    </div>
</form>
<script type="text/javascript">
    jQuery("#tabs").tabs();
</script>